package mortal.game.resource
{
	import Message.Db.Tables.*;
	import com.gengine.resource.*;
	import flash.utils.*;
	
	public class ErrorCodeConfig extends Object
	{
		private var _map:Dictionary;
		private static var _instance:ErrorCodeConfig;
		
		public function ErrorCodeConfig()
		{
			this._map = new Dictionary();
			if (_instance != null)
			{
				throw new Error(" ResConfig 单例 ");
			}
			this.init();
		}
		
		private function write(data:Object) : void
		{
			var errorCode:TErrorCode = null;
			var item:Object = null;
			for each (item in data)
			{
				
				errorCode = new TErrorCode();
				errorCode.errorCode = item.errorCode;
				errorCode.errorName = item.errorName;
				errorCode.errorStr = item.errorStr;
				errorCode.display = item.display;
				errorCode.showServerMsg = item.showServerMsg;
				this._map[errorCode.errorCode] = item;
			}
		}
		
		public function init() : void
		{
			var _loc_1:* = ConfigManager.instance.getJSONByFileName("t_error_code.json");
			this.write(_loc_1);
		}
		
		public function getInfoByCode(code:int) : TErrorCode
		{
			return this._map[code];
		}
		
		public function getErrorStringByCode(code:int) : String
		{
			var data:* = this._map[code];
			if (data)
			{
				return data.errorStr;
			}
			
			return "";
		}
		
		public static function get instance() : ErrorCodeConfig
		{
			if (_instance == null)
			{
				_instance = new ErrorCodeConfig;
			}
			return _instance;
		}
	}
}
